﻿/*
 * Monti
 * Created by: Jonathan Montiverdi
 * Date: 7/26/2012
 * License: http://jonathan.codeplex.com/license
 */
using System;
using System.Windows.Controls;
using Monti.DragAndDrop;
using Monti.Utilities;

namespace Monti.Docking
{
   /// <summary>
   /// Overrides the default behavior of a DragController.
   /// </summary>
   public class DockingDragController : DragController
   {
      /// <summary>
      /// Sets the drag data object.
      /// </summary>
      protected override void SetDragData()
      {
         base.SetDragData();
         if (this.DragData != null) return;
         var border = this.OriginalDragElement.FindVisualParent <Border> ();
         if (border != null)
         {
            if (border.Name == "ToolWindowTitle")
            {
               var itemsControl = this.DragSource as ItemsControl;
               this.DragData = itemsControl.Items [0];
            }
         }
      }
   }
}
